// pages/select_car_status/select_car_status.js
var orderCache = require('../../../utils/mr_xu/apply_order_cache.js') 
var common = require('../../../utils/mr_xu/common.js')
var api = require("../../../utils/mr_xu/api_url.js").api
var request = require("../../../utils/mr_xu/request.js")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    select:0,
    list:[
      '抵扣车',
      '抢盗车',
      '指标车',
      '查封车'
    ],
  },
  onLoad(options) {
    if (options.do == 'update') {
      let that = this
      let updateInfo = orderCache.getUpdateInfo()
      console.log(updateInfo)
      console.log(updateInfo.type)
      console.log(that.getSelectIndex(updateInfo.type))
      if (updateInfo) {
        that.setData({
          select: that.getSelectIndex(updateInfo.type)
        })
      }
    } else {
      //避免异常退出修改流程，导致想要新增的时候，走入了修改逻辑
      orderCache.deleteUpdateInfo()
    }
    
  },

  getSelectIndex(str) {
    return parseInt(str) - 1
  },

  select(e){
    let index = e.currentTarget.dataset.index
    console.log(index)
    this.setData({
      select:index
    })
  },

  next(){
    let that = this

    common.safeRun(function() {
      let index = that.data.select + 1
      orderCache.setItem('type', index != null ? index : 1)

      wx.navigateTo({
        url: '../step2_in_car_info/in_car_info',
      })
    })
  },

 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})